package com.kaishengit.service;

import java.util.List;

import com.kaishengit.dao.MessageDao;
import com.kaishengit.entity.Message;
import com.kaishengit.entity.UserProject;
import com.kaishengit.util.DateUtil;
import com.kaishengit.util.PkUtil;

public class MessageService {
	private MessageDao mDao=new MessageDao();
		
	public void save(String content, UserProject userProject) {
		Message m=new Message();
		m.setId(PkUtil.getId());
		m.setContent(content);
		m.setCreatetime(DateUtil.getNowDateTime());
		m.setUser(userProject.getUser());
		m.setUserId(userProject.getUser().getId());
		m.setProject(userProject.getProject());
		m.setProjectId(userProject.getProject().getId());
		mDao.save(m);
	}
	
	public List<Message> findMessage(UserProject userProject) {
		return mDao.findMessage(userProject);
	}
}
